package com.ie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ie.entity.Activity;
import com.ie.entity.Losspets;
import com.ie.entity.dto.LosspetsDto;
import com.ie.service.LosspetsService;
import com.ie.mapper.LosspetsMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author admin
* @description 针对表【losspets】的数据库操作Service实现
* @createDate 2025-03-02 22:16:12
*/
@Service
public class LosspetsServiceImpl
    implements LosspetsService{
    @Resource
    private LosspetsMapper losspetsMapper;

    @Override
    public List<Losspets> getAllLosspets() {
        List<Losspets> allLosspets = losspetsMapper.getAllLosspets();
        return allLosspets;
    }

    @Override
    public boolean deleteLosspets(String id) {

        return losspetsMapper.deleteLosspets(id);
    }

    @Override
    public List selectList(String name, String type, String city) {
        QueryWrapper wrapper = null;
        Map<String, String> map = new HashMap<>();
//        map.put("activityname",name);
        map.put("losstype", type);
        map.put("lostArea", city);
        wrapper = new QueryWrapper<Losspets>().allEq(map, false);

        List list = losspetsMapper.selectList(wrapper);
        return list;
    }

    @Override
    public void addLosspets(LosspetsDto losspetsDto) {
        Losspets losspets = new Losspets();
        losspets.setLossname(losspetsDto.getName());
        losspets.setLosstype(losspetsDto.getType());
        losspets.setBreed(losspetsDto.getBreed());
        losspets.setLostarea(losspetsDto.getCity());
        losspets.setLostlocation(losspetsDto.getLocation());
        losspets.setLossdescription(losspetsDto.getDescription());
        losspets.setPublisher(losspetsDto.getOwnerName());
        losspets.setContact(losspetsDto.getContactInfo());

        losspetsMapper.insert(losspets);
    }
}




